<!--
 * @Author: ChunLai
 * @Date: 2022-03-31 10:25:28
 * @LastEditTime: 2023-08-31 14:33:59
 * @Description: 投保条款文档阅读
 * @FilePath: \0.newInsure\src\views\read\index.vue
-->

<template>
  <div class="file_page-index" v-if="pageLoad">
    <PdfFile :fileObj="fileObj" v-if="fileType === 'pdf'" />
    <HtmlImg :fileObj="fileObj" v-else></HtmlImg>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import PdfFile from './PdfFile';
import HtmlImg from './HtmlImg';

export default {
  name: 'ReadPage',
  data() {
    return {
      fileType: 'pdf',
      fileObj: {},
      pageLoad: false,
    };
  },
  components: {
    HtmlImg,
    PdfFile,
  },
  computed: {
    ...mapGetters({
      comClauseList: 'page/comClauseList',
      apiClauseList: 'home/apiClauseList',
    }),
    insureFilesList() {
      return [...this.comClauseList, ...this.apiClauseList];
    },
  },
  created() {
    const querys = this.$route.query;
    if (querys.ftype) {
      this.fileType = querys.ftype;
    }
    if (querys.fid) {
      this.fileObj = this.insureFilesList.find((ele) => ele.id == querys.fid);
    }
    this.pageLoad = true;
  },
  methods: {},
};
</script>
